package com.wl.dzt.sys.fmk;

import freemarker.template.Configuration;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;


/**
 * @author wl_code@163.com
 * @version 1.0
 * @date 2018/7/2/002
 * @description freemarker 初始化
 */
@Component
public class InitFreemarker implements ApplicationRunner {

    /**
     * freemarker 初始化,以及初始化了模板
     *
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Fmkr.cfg = new Configuration(Configuration.VERSION_2_3_28);
        Fmkr.cfg.setClassForTemplateLoading(InitFreemarker.class, "/template");
//        Fmkr.cfg.setDirectoryForTemplateLoading(ResourceUtils.getFile("classpath:template"));
        Fmkr.cfg.setDefaultEncoding("UTF-8");
    }
}
